<?php
	require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/database.php';
	require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/doctype.php';
?>

    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
        <title>deviantPIC - Search user</title>
    </head>
    <body>
		<!-- Header -->
		<?php require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/header.php'; ?>

		<?php
			//Get user name
			$username = "";
			if (isset($_GET['user'])) $username = mysql_real_escape_string($_GET['user']);

			//Get page number
			$amount	= 10;
			$start	= 0;
			if (isset($_GET['start'])) $start = mysql_real_escape_string($_GET['start']);
		?>

		<!-- Content -->
		<div id="body">
			<h2>
				Result for <span class="searched">
				<?php
					echo $username;
				?></span>
			</h2>

			<!-- Users -->
			<div id="searched-users">
				<ul class="users">
					<?php
						//Get users
						$result = mysql_query("SELECT * FROM users WHERE username LIKE '%$username%'") or die(mysql_error());
						$count	= mysql_num_rows($result);

						//if there's a result
						if ($count > 0) {
							//List each user
							while ($user = mysql_fetch_array($result)) {
								echo "<li class='user'>
										<span class='searched-user-name'><a href=profile/index.php?id=" . $user['id'] . ">" . $user['username'] . "<a></span>
									</li>";
							}
						} else {
							echo "<span class='no-result'>No such user found.</span>";
						}
					?>
				</ul>
			</div>
		</div>

		<!-- Footer -->
		<?php require $_SERVER['DOCUMENT_ROOT'] . '/deviantpic/inc/footer.php'; ?>
    </body>
</html>